import request from '../utils/request'

export const clusterSearch = (data) =>{
  return request({ url: `/Search/clusterSearch`,method: 'post',data}).then(res=>{
    if(res.code == 200){
      debugger
      return {
        code:res.code,
        message: res.message,
        data:res.data,
        search_polar_data:res.search_polar_data
      }
    }else{
      return {
        code :res.code,
        message:res.message
      }
    }
  });
};

export const getDrugDiscribe = (data) =>{
  return request({ url: `/Search/getDrugDiscribe`,method: 'post',data}).then(res=>{
    if(res.code == 200){
      return {
        code:res.code,
        indications: res.indications,
        src:res.src
      }
    }else{
      return {
        code :res.code,
        message:res.message
      }
    }
  });
};


export const searchSurroundNodesTopk = (data) =>{
  return request({ url: `/Search/surroundTopk`,method: 'post',data}).then(res=>{
    if(res.code == 200){
      return {
        code:res.code,
        message: res.message,
        search_polar_data:res.search_polar_data,
        highlight_nodes:res.highlight_nodes,
        data:res.data
      }
    }else{
      return {
        code :res.code,
        message:res.message
      }
    }
  });
};

export const searchSurroundNodes = (data) =>{
  return request({ url: `/Search/surround`,method: 'post',data}).then(res=>{
    if(res.code == 200){
      debugger
      return {
        code:res.code,
        message: res.message,
        data:res.data,

      }
    }else{
      return {
        code :res.code,
        message:res.message
      }
    }
  });
};

export const searchDrug = (data) =>{
  return request({ url: `/Search/drug`,method: 'post',data}).then(res=>{
    if(res.code == 200){
      debugger
      return {
        code:res.code,
        message: res.message,
        data:res.data,
        highlight_nodes:res.highlight_nodes,
      }
    }else{
      return {
        code :res.code,
        message:res.message
      }
    }
  });
};

export const searchPrescription = (data) =>{
  return request({ url: `/Search/index`,method: 'post',data}).then(res=>{
    if(res.code == 200){
      debugger
      return {
        code:res.code,
        message: res.message,
        data:res.data,
        bestmatch:res.bestmatch,
        highlight_nodes:res.highlight_nodes,
        search_polar_data:res.search_polar_data
      }
    }else{
      return {
        code :res.code,
        message:res.message
      }
    }
  });
};

// 测试
export const testAPI = (data) =>{

  return request({ url: `/AutoMarkup/bertIndex`,method: 'post',data}).then(res=>{
    console.log(res)
    return {
      code:1,
      message: 'get',
      data:res
    }
  });
};
// 测试
export const getRequestKey = (info)=>new Promise((resolve)=>{
  let data = info
  // console.log(info)
  setTimeout(()=>{
    resolve(request({ url: `/TestForDFDA/PullRequestKeyAPI`,method: 'post' , data}).then(res => {
      console.log(res)
      return {
        code: 1,
        message: 'Get successfully',
        data: res.requestkeys
      }
  }));
  },2000)
});
